<template>
  <w-table-view
    :types="types"
    :search-bar-options="searchBarOptions"
    :list-data="listData"
    :content-box="false"
    :option="true"
    :remove-url="removeUrl"
    icon-name="pic"
    title-name="title"
    describe-name="date"
    detail-name="describe"
    detail-path="/web/study"
    edit-api="/admin/web/study/add"
    @reload="reloadData"
  />
</template>

<script>
import { Api, Admin } from '@/config/api'
import WTableView from '@/components/global/tableview/searchBar'
export default {
  layout: 'admin',
  name: 'AdminWebStudyList',
  components: {
    WTableView
  },
  async asyncData ({ app, route }) {
    const { $wAxios } = app
    const data = await Promise.all([
      $wAxios.$get(Api.study.types),
      $wAxios.$get(Api.study.list, route.query)
    ])
    return { types: data[0], listData: data[1] }
  },
  data () {
    return {
      searchBarOptions: ['所有', '标题', '描述', '内容'],
      removeUrl: Admin.study.delete,
      listData: []
    }
  },
  watch: {
    async '$route.query' () {
      await this.reloadData()
    }
  },
  methods: {
    async reloadData () {
      this.listData = await this.$wAxios.$get(Api.study.list, this.$route.query)
    }
  },
  head () {
    return {
      title: '学习总结列表'
    }
  }
}
</script>

<style scoped lang="less"></style>
